'use strict'
var fs=require('fs');

var data='我是从数据库获取的数据我要保存起来、\n\n';
var path="04 node中的fs模块";

var writerStream=fs.createWriteStream(`${path}/output.txt`);

writerStream.write(data,'utf8');



writerStream.on('finish',()=>{
    console.log('写入完成');
});

//标记写入完成
writerStream.end();

writerStream.on('error',(error)=>{
    throw error;
    console.log('写入失败');
});